// P1135 dfs 50pts TLE+MLE
#include <iostream>
#include <cstdio>
#include <cstring>

#define N 205

using namespace std;

bool vis[N];
int to[N];
int n, a, b;
int ans = 0x7ffffff;

void dfs(int now, int stp){
	memset(vis, false, sizeof(vis));
	if(now == b)	ans = ans > stp ? stp : ans;
	if(stp > ans)		return ;
	vis[now] = 1;
	if(now + to[now] <= n && !vis[now + to[now]])	dfs(now + to[now], ++stp);
	if(now - to[now] >= 1 && !vis[now - to[now]])	dfs(now - to[now], ++stp);
	vis[now] = 0;
}

int main(){
	cin >> n >> a >> b;
	for(int i = 1; i <= n; i++){
		scanf("%d", &to[i]);
	}
	dfs(a, 0);
	if(ans != 0x7ffffff)	cout << ans << "\n";
	else cout << -1 << "\n";
	return 0;
}